package demo1221.homework;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/*
1.编写一个类Book,具有name,price,press,author;
创建5个Book对象存放到ArrayList集合中，并实现按照price从小到大的顺序排序。
遍历ArrayList集合，输出每一个对象，展示对象的信息。
 */
public class Demo_01 {
    public static void main(String[] args) {
        List<Book> list = new ArrayList<>();
        list.add(new Book("活着",39.9,"人民出版社","余华"));
        list.add(new Book("平凡的世界",89.9,"人民出版社","路遥"));
        list.add(new Book("人生",59.9,"人民出版社","路遥"));
        Collections.sort(list);
        for (Book book : list) {
            System.out.println(book);
        }
    }
}
